﻿Imports DTO
Imports System.Runtime.InteropServices
Public Class CaTrucDAO
    Public Function LoadTinhTrangCaTruc() As DataTable
        Dim sql As String
        sql = "select * from NhanVien nv, CaTruc ct, TinhTrangNhanVien tt where nv.TinhTrang = tt.STT and nv.MaNV = ct.MaNV and nv.TinhTrang = 2 and ct.ThoiGianKT is null"
        Dim dt As DataTable
        dt = DataProvider.LoadSQL(sql)
        Return dt
    End Function
    Public Sub BatDauCaTruc(ByVal _ma As String)
        Dim sql As String
        sql = String.Format("insert into CaTruc values ({0},'{1}',null)", _ma, DateTime.Now)
        DataProvider.ExcuteQuery(sql)
        sql = "update NhanVien set TinhTrang = 2 where MaNV= " + _ma.ToString
        DataProvider.ExcuteQuery(sql)
    End Sub
    Public Sub KetThucCaTruc(ByVal _ma As String)
        Dim sql As String
        sql = String.Format("update CaTruc set ThoiGianKT = '{0}' where ThoiGianKT is null and MaNV = {1}", DateTime.Now, _ma)
        DataProvider.ExcuteQuery(sql)
        sql = "update NhanVien set TinhTrang = 1 where MaNV= " + _ma.ToString
        DataProvider.ExcuteQuery(sql)
    End Sub
End Class
